
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { Flashlight } from 'ionic-native';


/*
  手电筒
  http://ionicframework.com/docs/v2/native/flashlight/
*/

@Component({
  selector: 'page-flashlight',
  templateUrl: 'flashlight.html'
})
export class FlashlightPage {

  public sdt=true;

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
  ) {

  }

  getFlashlight(bool) {
    if (bool===true){
      Flashlight.switchOn();
      this.sdt=false;
    }else if (bool===false){
      Flashlight.switchOff();
      this.sdt=true;
    }
  }

  getFltoggle(){
    if (Flashlight.isSwitchedOn()){
      Flashlight.toggle();
      this.sdt=!this.sdt;
    }else{
      Flashlight.toggle();
      this.sdt=!this.sdt;
    }
  }

}
